public class Test {

    public static void main(String[] args) throws InterruptedException {

        LimitedCounter limter = new SlidingWindowsCounter(2000,1000);

        Thread[] threads = new Thread[40];
        for(int a = 0;a<threads.length;a++) {
            final int threadNum = a;
            threads[a] = new Thread(()->{
                for(int i=0;i<1000000;i++) {
                    try {
                        limter.getTokenWithBlocking();
                        System.out.println(Thread.currentThread().getName()+" : "+(threadNum*10000+i));
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }

        for(Thread thread:threads) {
            thread.start();
        }
    }
}
